# !/usr/usuari/des python
#  -*- coding: utf-8 -*-
"""
@Author        : itgnay
@Time          : 2022/12/22 20:20
@FileName      : 选择排序.py
@LastEditors   : None
@Editors       : PyCharm
"""
# 不稳定
'''
寻找最值，直接换位置
与冒泡类似，但冒泡是一步一步挪
'''

nums_list = [14, 33, 27, 10, 35, 19, 42, 44]


def selection_sort(nums_list):
    for i in range(len(nums_list)):
        min_num = nums_list[i]
        position = i
        for j in range(i, len(nums_list)):
            if min_num > nums_list[j]:
                min_num = nums_list[j]
                position = j
        nums_list[i], nums_list[position] = nums_list[position], nums_list[i]
    return nums_list


nums_list = selection_sort(nums_list)
print(nums_list)
